package com.snopy.controller;

import com.snopy.common.JSONResult;
import com.snopy.pojo.bo.ShopcartBO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * TODO
 *
 * @author snoopy
 * @date 2020/9/18 0018 23:14
 * @email 77912204@qq.com
 * @remark
 */
@Api(value = "购物车controller",tags = "购物车")
@RestController
@RequestMapping("shopcart")
public class ShopcartConroller {


    @ApiOperation(value = "添加购物车",notes = "添加购物车",httpMethod = "POST")
    @PostMapping("/add")
    public JSONResult add(
            @RequestParam String userId,
            @RequestBody ShopcartBO shopcartBO,
            HttpServletRequest request,
            HttpServletResponse response
    ){
        if (StringUtils.isEmpty(userId)){
            return JSONResult.errorMsg("用户id");
        }
        System.out.println(shopcartBO);
        //TODO 前端用户在登录的情况下，添加商品到购物车，会同时在后端同步购物车到redis缓存


        return JSONResult.ok();
    }


}
